<?php 
	require_once('class.db.php');
	class trangchu extends db {
		function config($lang){
			$qr = "SELECT * FROM `config` WHERE `delete`=0 AND `status`=1 AND `lang`='{$lang}'";
			return mysql_query($qr);
		}
		function html($domain,$lang){
			$str = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>';
			$str .= "<base href=\"http://{$domain}/\" />";
			$str .= "<meta http-equiv=\"content-language\" content =\"{$lang}\" />";
			$str .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";
			echo $str;
		}
		function seo($domain,$title,$description,$keywords,$image,$url){
			$str = "
<title>{$title}</title>
<meta name=\"description\" content=\"{$description}\" />
<meta name=\"keywords\" content=\"{$keywords}\" />
<meta name=\"title\" content=\"{$title}\" />
<meta name=\"robots\" content=\"NOODP\" />
<meta property=\"og:title\" content=\"{$title}\" />
<meta property=\"og:image\" content=\"http://{$domain}{$image}\" />
<meta property=\"og:site_name\" content=\"{$domain}\" />
<meta property=\"og:url\" content=\"http://{$domain}{$url}\" />
<meta property=\"og:description\" content=\"{$description}\" />";
			echo $str;
		}
		function css_script($css_script){
			for($i=0; $i<=count($css_script); $i++) $str .= $css_script[$i];
			$str .= '</head><body>';
			echo $str;
		}
		function sanphammoi(){
			$qr = "SELECT id,name,name_rewrite,url_hinh,price,menu_id FROM product WHERE `delete`=0 AND status=1 ORDER BY date_update DESC LIMIT 6";
			return mysql_query($qr);
		}
		function sanphamtieubieu(){
			$qr = "SELECT id,name,name_rewrite,url_hinh,price,menu_id FROM product WHERE `delete`=0 AND status=1 AND other1=1 ORDER BY date_update DESC LIMIT 6";
			return mysql_query($qr);
		}
		function menu_one($id){
			$qr = "SELECT id,name,name_rewrite,url,url_hinh,title,metaDescription,metaKeyword,type_id FROM menu WHERE `delete`=0 AND status=1 AND id='{$id}'";
			return mysql_query($qr);
		}
		function menu($level,$position,$lang){
			$qr = "SELECT id,name,url FROM menu WHERE `delete`=0 AND status=1 AND lang='{$lang}' AND position_id LIKE '%,{$position},%' AND parent_id = {$level} ORDER BY `order`";
			return mysql_query($qr);
		}
		function getSubmenu($level,$position,$lang){
			$sql = $this->menu($level,$position,$lang);
			if(mysql_num_rows($sql) > 0){
				echo '<ul>';
				while($row = mysql_fetch_array($sql)){
					echo "<li><a href=\"{$row['url']}\" >{$row['name']}</a>";
					$this->getSubmenu($row['id'],$position,$lang);
					echo '</li>';
				}
				mysql_free_result($sql);
				echo '</ul>';
			}
		}
		function menu_left($id){
			$qr = "SELECT id,name,url FROM menu WHERE `delete`=0 AND status=1 AND parent_id={$id} ORDER BY `order`";
			return mysql_query($qr);
		}
		function thongtinmoi(){
			$qr = "SELECT id,name,name_rewrite,url_hinh,menu_id FROM info WHERE `delete`=0 AND status=1 ORDER BY date_update DESC LIMIT 5";
			return mysql_query($qr);
		}
		function videomoi(){
			$qr = "SELECT id,name,name_rewrite,link_video,menu_id FROM video WHERE `delete`=0 AND status=1 AND `other`=1 ORDER BY date_update DESC LIMIT 5";
			return mysql_query($qr);
		}
		// GET link
		function id_info($alias){
			$qr = "SELECT id FROM info WHERE `delete`=0 AND status=1 AND name_rewrite='$alias'";
			$row = mysql_fetch_array(mysql_query($qr));
			return $row['id'];
		}
		function id_menu($alias){
			$qr = "SELECT id FROM menu WHERE `delete`=0 AND status=1 AND name_rewrite='$alias'";
			$row = mysql_fetch_array(mysql_query($qr));
			return $row['id'];
		}
		/*
		* navigator
		*/
		function navigator($id){
			$qr = $this->menu_one($id);
			$row = mysql_fetch_array($qr);
			mysql_free_result($qr);
			$str = "<div class=\"title\">{$row['name']}</div>";
			return $str;
		}
		/*
		* loai danh muc
		*/
		function type_catalog($idMenu,$domain,$page){
			$qr = $this->menu_one($idMenu);
			$row = mysql_fetch_array($qr);
			mysql_free_result($qr);
			
			$url = $row['url'];
			$title = $row['title'];
			$image = 'images/logo.jpg';
			$seo = $this->seo($domain,$title,$row['metaDescription'],$row['metaKeyword'],$image,$url);
			
			switch($row['type_id']){
				case 2 : $type = $this->catalog_info($idMenu,$row['name'],$url,$page); break;
				case 4 : $type = $this->catalog_picture($idMenu,$row['name'],$url,$page); break;
				case 5 : $type = $this->catalog_video($idMenu,$row['name'],$url,$page); break;
				case 6 : $type = $this->catalog_contact(); break;
				default : $type = does_not_exist;
			}
			return $str = array($seo,$type);
		}
		function list_item($select,$table,$where,$limit=NULL){
			$qr = "SELECT {$select} FROM {$table} WHERE {$where} ORDER BY date_update DESC {$limit}";
			return mysql_query($qr);
		}
		function catalog_info($idMenu,$name_menu,$url,$page){
			$from = (($page * max_news) - max_news);
			
			$select = 'id,name,name_rewrite,url_hinh,description,content,date_create,menu_id';
			$table = 'info';
			$where = "`delete`=0 AND status=1 AND menu_id LIKE '%,{$idMenu},%'";
			$limit = "LIMIT {$from},".max_news;
			
			$navigator = '<div id="navigator"><img style="float:left" src="images/title_1.png" alt="" /><p>'.$name_menu.'</p><img style="float:right" src="images/title_3.gif" alt="" /></div>';
			$qr = $this->list_item($select,$table,$where,$limit);
			if(mysql_num_rows($qr) > 1){
				$view = '<div id="viewpost">'.$navigator.'<div style="clear:both; margin:10px 10px">';
				while($row = mysql_fetch_array($qr)){
					$url_link = $this->link_detail($row['menu_id']);
					($row['url_hinh']!= '') ? $url_hinh = url_hinh_info_thumbs.$row['url_hinh'] : $url_hinh='upload/no-image.jpg';
					$view .= "
					<div class=\"item\">
						<a href=\"{$url_link}{$row['name_rewrite']}.html\"><img src=\"{$url_hinh}\" alt=\"{$row['name']}\" />
						<h4>{$row['name']}</h4></a>
						<p>{$row['description']}</p>
						<div style=\"height:10px; clear:both\"></div>
					</div>";
				}
				mysql_free_result($qr);
				$phantrang = $this->phantrang($url,$page,max_news,'id',$table,$where);
				$view .= "</div><div id=\"phantrang\">{$phantrang}</div></div><!--end viewpost-->";
			} else {
				$row = mysql_fetch_array($qr);
				$view = "<div id=\"viewpost\">{$navigator}<div style=\"clear:both; margin:10px 10px\"><p class=\"date\">".date('H:i | d-m-Y', strtotime($row['date_create']))."</p><h1>{$row['name']}</h1><div>{$row['content']}</div></div></div>";
			}
			return $view;
		}
		function catalog_product($idMenu,$name_menu,$url,$page){
			$from = (($page * max_product) - max_product);
			
			$select = 'id,name,name_rewrite,url_hinh,description,price,menu_id';
			$table = 'product';
			$where = "`delete`=0 AND status=1 AND menu_id LIKE '%,{$idMenu},%'";
			$limit = "LIMIT {$from},".max_product;
			
			$qr = $this->list_item($select,$table,$where,$limit);
			
			while($rowsp = mysql_fetch_array($qr)){
				$url_link = $this->link_detail($rowsp['menu_id']);
				if($idMenu != 27) $buy = "<p>Giá: <span>".number_format($rowsp['price'])." vnđ</span></p><p><a href=\"javascript:;\" class=\"buy\" id=\"{$rowsp['id']}\" name='{$rowsp['name']}'>Mua</a></p>";
				else $buy = '';
				$view .= "
				<div class=\"itemproduct\">
					<a href=\"{$url_link}{$rowsp['name_rewrite']}-d{$rowsp['id']}.html\">
						<img src=\"".url_hinh_product_thumbs."{$rowsp['url_hinh']}\" alt=\"{$rowsp['name']}\" />
						<h3>{$rowsp['name']}</h3>
					</a>{$buy}
				</div>
				";
			}
			mysql_free_result($qr);
			$phantrang = $this->phantrang($url,$page,max_product,'id',$table,$where);
			$view .= "<div id=\"phantrang\">{$phantrang}</div>";
			
			$navigator = "<div class=\"title\"><h1>{$name_menu}</h1></div>";
			$view = $navigator.$view;
			return $view;
		}
		function catalog_picture($idMenu,$name_menu,$url,$page){
			$from = (($page * max_picture) - max_picture);
			
			$select = 'id,name,name_rewrite,url_hinh';
			$table = 'menu';
			$where = "`delete`=0 AND status=1 AND type_id=4 AND parent_id=4";
			//$limit = "LIMIT {$from},".max_picture;
			
			$navigator = '<div id="navigator"><img style="float:left" src="images/title_1.png" alt="" /><p>'.$name_menu.'</p><img style="float:right" src="images/title_3.gif" alt="" /></div>';
			$view = '<div id="viewpost">'.$navigator.'<div style="clear:both; margin:10px 0 10px 15px">';
			
			$view .= '<div style="line-height:30px; color:#C6262D; text-decoration:underline"><h2>Hình ảnh</h2></div>';
			$qr = $this->list_item($select,$table,$where);
			while($row = mysql_fetch_array($qr)){
				$view .= "<div class='item_thuvien'><a href='thu-vien/{$row['name_rewrite']}.html'><img src='".url_hinh_menu."{$row['url_hinh']}' alt='{$row['name']}' /><h3>{$row['name']}</h3></a></div>";
			}
			$where = "`delete`=0 AND status=1 AND type_id=3 AND parent_id=4";
			$view .= '<div style="clear:both; height:20px"></div>  <div style="line-height:30px; color:#C6262D; text-decoration:underline;"><h2>Tài liệu</h2></div>';
			$qr = $this->list_item($select,$table,$where);
			while($row = mysql_fetch_array($qr)){
				$view .= "<div class='item_thuvien'><a href='thu-vien/{$row['name_rewrite']}.html'><img src='".url_hinh_menu."{$row['url_hinh']}' alt='{$row['name']}' /><h3>{$row['name']}</h3></a></div>";
			}
			mysql_free_result($qr);
			
			//$phantrang = $this->phantrang($url,$page,max_picture,'id',$table,$where);
			//$view .= "</div><div id=\"phantrang\">{$phantrang}</div></div><!--end viewpost-->";
			return $view.'</div></div>';
		}
		function catalog_video($idMenu,$name_menu,$url,$page){
			$from = (($page * max_video) - max_video);
			
			$select = 'id,name,name_rewrite,url_hinh,description,menu_id';
			$table = 'video';
			$where = "`delete`=0 AND status=1 AND menu_id LIKE '%,{$idMenu},%'";
			$limit = "LIMIT {$from},".max_video;
			
			$qr = $this->list_item($select,$table,$where,$limit);
			$view = '<div id="listinfo">';
			while($row = mysql_fetch_array($qr)){
				$url_link = $this->link_detail($row['menu_id']);
				$view .= "<div class=\"item\">
					<a href=\"{$url_link}{$row['name_rewrite']}.html\"><img src=\"".url_hinh_video_thumbs."{$row['url_hinh']}\" alt=\"\" />
					<h4>{$row['name']}</h4></a>
					<p>{$row['description']}</p>
					<div style=\"height:10px; clear:both\"></div>
				</div>";
			}
			mysql_free_result($qr);
			$phantrang = $this->phantrang($url,$page,max_video,'id',$table,$where);
			$view .= "</div><div id=\"phantrang\">{$phantrang}</div>";
			
			$navigator = "<div class=\"title\"><h1>{$name_menu}</h1></div>";
			$view = $navigator.$view;
			return $view;
		}
		function catalog_contact(){
			include_once('blocks/contact.php');
			return $contact;
		}
		/*
		* Phan trang
		*/
		function phantrang($link,$page_number,$max_results,$select,$table,$where,$keyword=NULL,$catalog=NULL,$order=NULL){
			$qr = $this->list_item($select,$table,$where);
			$total = mysql_num_rows($qr);
			mysql_free_result($qr);
			
			$str = '<div style="clear:both"></div>';
			$total_pages = ceil($total / $max_results);
			if($total_pages > 1){
				if($page_number > 1){
					$prev = ($page_number - 1);
					$str .= "<a href='{$link}{$prev}/'>Trang trước</a>";
				}
				for($i = $page_number - 5; $i <= $page_number + 5 & $i <= $total_pages; $i++){
					if($page_number == $i){
						$str .= "<a href='{$link}{$i}/' style='color:#F00; font-weight:bold; background-color:#ffffcc'>{$i}</a>";
					} elseif($i>0) {
						$str .= "<a href='{$link}{$i}/'>{$i}</a>";
					}
				}
				if($page_number < $total_pages){
					$next = ($page_number + 1);
					$str .= "<a href='{$link}{$next}/'>Trang sau</a>";
				}
			}
			return $str;
		}
		/*
		* loai noi dung
		*/
		function type_detail($idMenu,$detail,$domain){
			$qr = $this->menu_one($idMenu);
			$row = mysql_fetch_array($qr);
			mysql_free_result($qr);
			$link = $row['url'];
			switch($row['type_id']){
				case 2 : $type = $this->detail_info($idMenu,$row['name'],$detail,$link,$domain); break;
				case 4 : $type = $this->detail_picture($detail,$link,$domain); break;
				case 5 : $type = $this->detail_video($idMenu,$row['name'],$detail,$link,$domain); break;
				default : $type = does_not_exist;
			}
			return $type;
		}
		function detail_info($idMenu,$name_menu,$detail,$link,$domain){
			$qr = mysql_query("SELECT id,name,name_rewrite,url_hinh,date_create,description,content,metaKeyword FROM info WHERE `delete`=0 AND status=1 AND id='{$detail}'");
			$row = mysql_fetch_array($qr);
			mysql_free_result($qr);
			$navigator = '<div id="navigator"><img style="float:left" src="images/title_1.png" alt="" /><p>'.$name_menu.'</p><img style="float:right" src="images/title_3.gif" alt="" /></div>';
			$view = "<div id=\"viewpost\">{$navigator}<div style=\"clear:both; margin:10px 10px\"><p class=\"date\">".date('H:i | d-m-Y', strtotime($row['date_create']))."</p><h1>{$row['name']}</h1><div>{$row['content']}</div></div></div><!--end viewpost-->";
			//$ykien = $this->ykien($detail,'info_comment');
			//$cungloai = $this->infocungloai($idMenu,$detail);
			$rewrite = str_replace('-',' ',$row['name_rewrite']);
			$title = "{$row['name']}, {$rewrite}";
			$url = "{$link}{$row['name_rewrite']}.html";
			$url_hinh = url_hinh_info_thumbs.$row['url_hinh'];
			$seo = $this->seo($domain,$title,$row['description'],$row['metaKeyword'].','.$rewrite,$url_hinh,$url);
			return $str = array($seo,$view.$ykien.$cungloai);
		}
		function detail_product($idMenu,$name_menu,$detail,$link,$domain){
			$qr = mysql_query("SELECT id,name,name_rewrite,url_hinh,date_create,description,content,metaKeyword,other,price FROM product WHERE `delete`=0 AND status=1 AND id='{$detail}'");
			$row = mysql_fetch_array($qr);
			mysql_free_result($qr);
			$navigator = "<div class=\"title\">{$name_menu}</div>";
			if($idMenu != 27) $buy="<p><b>Giá: <span style=\"color:red\">".number_format($row['price'])."đ</span></b></p><p><a href=\"javascript:;\" class=\"buy\" id=\"{$row['id']}\" name='{$row['name']}'><img src=".btn_buy." /></a></p>";
			else $buy='';
			$view = "{$navigator}<div id=\"viewpost\"><p class=\"date\">".date('H:i | d-m-Y', strtotime($row['date_create']))."</p><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign='top'><img class=\"img\" src=\"".url_hinh_product.$row['url_hinh']."\" alt=\"{$row['name']}\"></td><td valign='top'><h1>{$row['name']}</h1><p>{$row['other']}</p> {$buy}</td></tr></table><div>{$row['content']}</div></div>";
			$ykien = $this->ykien($detail,'product_comment');
			$spcungloai = $this->sanphamcungloai($idMenu,$detail);
			$rewrite = str_replace('-',' ',$row['name_rewrite']);
			$title = "{$row['name']}, {$rewrite}";
			$url = "{$link}{$row['name_rewrite']}.html";
			$url_hinh = url_hinh_product_thumbs.$row['url_hinh'];
			$seo = $this->seo($domain,$title,$row['description'],$row['metaKeyword'].','.$rewrite,$url_hinh,$url);
			return $str = array($seo,$view.$ykien.$spcungloai);
		}
		function detail_picture($detail,$link,$domain){
			$qr = $this->menu_one($detail);
			$row_qr = mysql_fetch_array($qr);
			
			$navigator = '<div id="navigator"><img style="float:left" src="images/title_1.png" alt="" /><p>'.$row_qr['name'].'</p><img style="float:right" src="images/title_3.gif" alt="" /></div>';
			$view = '<div id="viewpost">'.$navigator.'<div style="clear:both; height:10px"></div>';
			$type2 = mysql_query("SELECT type_id FROM menu WHERE id='{$detail}'");
			$row_type2 = mysql_fetch_array($type2);
			$qr = mysql_query("SELECT name,url_hinh FROM photo_gallery WHERE `delete`=0 AND status=1 AND menu_id LIKE '%,{$detail},%'");
			if($row_type2['type_id']==4){
				$view .= '<div id="photos"><ul class="gallery clearfix">';
				while($row = mysql_fetch_array($qr)){
					$view .= '<li><a href="'.url_hinh_picture.$row['url_hinh'].'" rel="prettyPhoto[gallery1]"><img class="img" src="'.url_hinh_picture_thumbs.$row['url_hinh'].'" alt="'.$row['name'].'" /></a></li>';
				}
				$view .= '</ul></div>  <link rel="stylesheet" href="slider_pic/prettyPhoto.css" type="text/css" media="screen" charset="utf-8" /><!--end photo-->';
			}else{
				$view .= '<div style="clear:both; height:10px"></div>';
				$ii = 0;
				while($row = mysql_fetch_array($qr)){
					$ii++;
					$view .= '<a href="'.url_hinh_tailieu.$row['url_hinh'].'" target="_blank"><h3 style="line-height:22px; margin:10px 0">'.$ii.'/ '.$row['name'].'</h3></a>';
				}
			}
			
			$view .= '<div style="clear:both; height:10px"></div></div><!--end viewpost-->';
			//$ykien = $this->ykien($detail,'photo_gallery_comment');
			$title = "{$row_qr['name']}";
			$url = "{$link}{$row_qr['name_rewrite']}-d{$row_qr['id']}.html";
			$url_hinh = url_hinh_menu_thumbs.$row_qr['url_hinh'];
			$seo = $this->seo($domain,$title,$row_qr['metaDescription'],$row_qr['metaKeyword'],$url_hinh,$url);
			return $str = array($seo,$view);
		}
		function detail_video($idMenu,$name_menu,$detail,$link,$domain){
			$qr = mysql_query("SELECT id,name,name_rewrite,url_hinh,link_video,date_create,description,content,metaKeyword FROM video WHERE `delete`=0 AND status=1 AND id='{$detail}'");
			$row = mysql_fetch_array($qr);
			mysql_free_result($qr);
			$navigator = "<div class=\"title\">{$name_menu}</div>";
			$view = "{$navigator}<div id=\"viewpost\">
			<p class=\"date\">".date('H:i | d-m-Y', strtotime($row['date_create']))."</p>
			<h1>{$row['name']}</h1>
			<p><iframe name='{$row['name']}' id='videoview' src='{$row['link_video']}?autoplay=1&origin=http://{$domain}&rel=0' frameborder='0'></iframe></p>
			<div>{$row['content']}</div>
			</div>";
			$ykien = $this->ykien($detail,'video_comment');
			$cungloai = $this->videocungloai($idMenu,$detail);
			$rewrite = str_replace('-',' ',$row['name_rewrite']);
			$title = "{$row['name']}, {$rewrite}";
			$url = "{$link}{$row['name_rewrite']}.html";
			$url_hinh = url_hinh_product_thumbs.$row['url_hinh'];
			$seo = $this->seo($domain,$title,$row['description'],$row['metaKeyword'].','.$rewrite,$url_hinh,$url);
			return $str = array($seo,$view.$ykien.$cungloai);
		}
		function ykien($id,$from){
			$qr = mysql_query("SELECT content, name FROM {$from} WHERE status=1 AND parent_id={$id}");
			$str = '<div id="guiykien"><a href="javascript:;">Gửi ý kiến</a></div>
			<div id="formykien"><h4>Thông tin ý kiến</h4><p><input type="text" name="name" value="Họ tên" maxlength="50" class="txt" /></p><p><input type="text" name="email" value="Email" maxlength="50" class="txt" /></p><p><textarea class="textarea" name="content"></textarea></p><p><input type="button" name="btnSub" value="Gửi" class="btn" /><input type="button" name="btnCancel" value="Hủy" class="btn" /></p><input type="hidden" name="id" value="'.$id.'" /><input type="hidden" name="form" value="'.$from.'" /></div>';
			if(mysql_num_rows($qr) > 0){
				$str .= "<div class='title'>".ykien_khach_hang.'</div>';
				while($row = mysql_fetch_array($qr)){
					$str .= "<div class=\"item_ykien\"><h5>{$row['name']}</h5>
					<p>{$row['content']}</p></div>";
				}
				mysql_free_result($qr);
			}
			return $str;
		}
		function guiykien($table,$id,$name,$email,$content){
			$date = date('Y-m-d H:i:s');
			$qr = "INSERT INTO {$table} (`date_create`,`content`,`email`,`name`,`parent_id`) VALUES ('{$date}','{$content}','{$email}','{$name}','{$id}')";
			mysql_query($qr);
		}
		function sanphamcungloai($idMenu,$detail){
			$rewrite_menu = mysql_fetch_array($this->menu_one($idMenu));
			$str = "<div class='title'>".sp_cung_loai.'</div>';
			$qr = mysql_query("SELECT id,name,name_rewrite,url_hinh,price,menu_id FROM product WHERE `delete`=0 AND status=1 AND id<>{$detail} AND menu_id LIKE '%,{$idMenu},%' ORDER BY rand() LIMIT 3");
			while($rowsp = mysql_fetch_array($qr)){
				if($idMenu != 27) $buy="<p>Giá: <span>".number_format($rowsp['price'])." vnđ</span></p><p><a href=\"javascript:;\" class=\"buy\" id=\"{$rowsp['id']}\" name='{$rowsp['name']}'>Mua</a></p>";
				else $buy='';
				$str .= "
				<div class=\"itemproduct\">
					<a href=\"{$rewrite_menu[url]}{$rowsp['name_rewrite']}-d{$rowsp['id']}.html\">
						<img src=\"".url_hinh_product_thumbs."{$rowsp['url_hinh']}\" alt=\"{$rowsp['name']}\" />
						<h3>{$rowsp['name']}</h3>
					</a>{$buy}
				</div>
				";
			}
			mysql_free_result($qr);
			return $str;
		}
		function videocungloai($idMenu,$detail){
			$rewrite_menu = mysql_fetch_array($this->menu_one($idMenu));
			$str = "<div class='title'>".video_cung_loai.'</div><div class="videocungloai">';
			$qr = mysql_query("SELECT id,name,name_rewrite FROM video WHERE `delete`=0 AND status=1 AND id<>{$detail} AND menu_id LIKE '%,{$idMenu},%' ORDER BY date_update DESC LIMIT 8");
			while($rowsp = mysql_fetch_array($qr)){
				$str .= "<a href=\"{$rewrite_menu['url']}{$rowsp['name_rewrite']}-d{$rowsp['id']}.html\"><h3>+ {$rowsp['name']}</h3></a>";
			}
			$str .= '</div>';
			mysql_free_result($qr);
			return $str;
		}
		function infocungloai($idMenu,$detail){
			$rewrite_menu = mysql_fetch_array($this->menu_one($idMenu));
			$str = "<div class='title'>".info_cung_loai.'</div><div class="videocungloai">';
			$qr = mysql_query("SELECT id,name,name_rewrite FROM info WHERE `delete`=0 AND status=1 AND id<>{$detail} AND menu_id LIKE '%,{$idMenu},%' ORDER BY date_update DESC LIMIT 8");
			while($rowsp = mysql_fetch_array($qr)){
				$str .= "<a href=\"{$rewrite_menu[url]}{$rowsp['name_rewrite']}-d{$rowsp['id']}.html\"><h3>+ {$rowsp['name']}</h3></a>";
			}
			$str .= '</div>';
			mysql_free_result($qr);
			return $str;
		}
		function link_detail($menu_id){
			$str = explode(',',$menu_id);
			$i = count($str)-2;
			$m = $this->menu_one($str[$i]);
			$row_m = mysql_fetch_array($m);
			return $row_m['url'];
		}
		function slider_banner($position,$idMenu){
			$qr = "SELECT name,url_hinh,link FROM slider_banner WHERE `delete`=0 AND status=1 AND position_id={$position} AND menu_id LIKE '%,{$idMenu},%' ORDER BY date_update DESC";
			return mysql_query($qr);
		}
	}// end trangchu